package com.kotlin.flong.reflection

import kotlin.reflect.full.functions


/**
 * @Author:liangjl
 * @Date: 2020/7/12-8:07
 * @Eamil:jilongliang@sina.com
 * @Description:
 */
class MyTest7 {
    fun printSomeThing(name: String) {
        println("printSomeThing, $name")
    }

    fun printNoThing() {
        println("printNoThing ")
    }
}

fun main() {
    var myTestClass7 = MyTest7::class
    var myTest7Obj = MyTest7()
    //获取所有的function函数
    var functionInvoke = myTestClass7.functions.find { it.name == "printNoThing" }
    //加上一个？，如果functionInvoke表示对象为空的话，后面的代码方法就不会进行调用，call是一个可变函数
    functionInvoke?.call(myTest7Obj)

    var functionInvoke2 = myTestClass7.functions.find { it.name == "printSomeThing" }
    functionInvoke2?.call(myTest7Obj, "hello world")


}